package cn.e4j.modular.common.service.impl;

import cn.e4j.config.properties.E4jProperties;
import cn.e4j.core.common.annotion.MethodDescription;
import cn.e4j.core.dto.Dtos;
import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.dto.requestDtoResolver.DtoParam;
import cn.e4j.core.dto.requestDtoResolver.DtoWapper;
import cn.e4j.core.shiro.ShiroKit;
import cn.e4j.core.shiro.ShiroUser;
import cn.e4j.core.util.AppCxt;
import cn.e4j.core.util.InvokeUtil;
import cn.e4j.core.util.LangUtils;
import cn.e4j.core.util.StringUtils;
import cn.e4j.modular.common.entity.SysOrgT;
import cn.e4j.modular.common.mapper.*;
import cn.e4j.modular.common.service.SysAuthorityService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 系统数据权限 服务实现类
 * </p>
 *
 * @author ganjia
 * @since 2019-03-05
 */
@Service
public class QueryServiceImpl extends ServiceImpl<QueryMapper, SysOrgT> {
    @Autowired
    YFQueryMapper YFMapper;
    @Autowired
    E10QueryMapper E10Mapper;
    @Autowired
    GPQueryMapper GPMapper;
    @Autowired
    T100QueryMapper T100Mapper;
    @Autowired
    SysAuthorityService sysAuthorityService;
    @Autowired
    E4jProperties e4jProperties;

    /**
     * 客户开窗
     * arg1 ENT
     * arg2 LANG
     * @author ganjia
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwak001",description = "客户资料开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwak001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        ShiroUser shiroUser = ShiroKit.getUser();
        inDto.put("ent", shiroUser.getDBC());
        inDto.put("lang", LangUtils.getLang(shiroUser.getLANG()));
        if(inDto.getString("ent").equals(null)){
            inDto.put("ent", "80");
        }
        if(inDto.getString("lang").equals(null)){
            inDto.put("lang", "2");
        }

        //处理多选时过滤记录
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(",");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }

        listData = this.baseMapper.q_gwak001(page, inDto);

        return listData;
    }

    /**
     * 客户开窗
     * arg1 GWAK006:客户类型
     * arg2 GWEB001:商机主题
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwak001_1",description = "客户开窗(权限)",parameter = "{arg1:ENT,arg2:LANG,arg3:GWAK006,arg4:GWEB001}")
    public List<Dto> cq_gwak001_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        inDto.put("CUSTOMERS",this.sysAuthorityService.getCustomersAuthority(inDto));

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwak001_1(page, inDto);

        return listData;
    }


    /**
     * 客户开窗
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwak001_2",description = "客户开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> cq_gwak001_2(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwak001_2(page, inDto);

        return listData;
    }

    /**
     * 客户开窗
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwak001_3",description = "客户开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> cq_gwak001_3(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwak001_3(page, inDto);

        return listData;
    }

    /**
     * 组织开窗
     * arg1 TYPE:组织类型 前端传入
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_sysorg_id",description = "组织开窗",parameter = "{arg1:TYPE}")
    public List<Dto> q_sysorg_id(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //处理多选时过滤记录
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(",");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_sysorg_id(page, inDto);

        return listData;
    }

    /**
     * 业务员（用户）开窗
     * arg1 ENT
     * arg2 ORG_ID:归属组织 前端传入
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_sysuser_id",description = "业务员（用户）开窗",parameter = "{arg1:ENT,arg2:ORG_ID}")
    public List<Dto> q_sysuser_id(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //部门权限
        Boolean permission = inDto.getBoolean("org_permission");
        if (permission!= null && permission){
            List<Dto> orgs = sysAuthorityService.getOrgsAuthority(inDto);
            inDto.put("ORGS", orgs);
        }

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_sysuser_id(page, inDto);

        return listData;
    }

    /**
     * 业务员开窗
     * arg1:ENT
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_sysuser_id_1",description = "业务员（用户）开窗",parameter = "{arg1:ENT}")
    public List<Dto> cq_sysuser_id_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_sysuser_id_1(page, inDto);

        return listData;
    }

    /**
     * 业务员开窗（查询条件）
     * arg1:ENT
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_sysuser_id_2",description = "业务员开窗",parameter = "{arg1:ENT}")
    public List<Dto> cq_sysuser_id_2(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_sysuser_id_2(page, inDto);

        return listData;
    }

    /**
     * 项目开窗
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwem001",description = "项目开窗",parameter = "")
    public List<Dto> q_gwem001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwem001(page, inDto);

        return listData;
    }

    /**
     * 销售渠道开窗
     * arg1 hasPermission 是否带权限(默认为false)
     * arg2 ENT
     * arg3 LANG
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwae001",description = "销售渠道开窗",parameter = "{arg1:hasPermission,arg2:ENT,arg3:LANG}")
    public List<Dto> q_gwae001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        String hasPermission = inDto.getString("hasPermission");

        //处理多选时过滤记录
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(",");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }

        // 如果没有传参，设置默认值为false
        if(hasPermission == null) {
            hasPermission = "false";
        }
        if(hasPermission.equals("true")){
            inDto.put("GWAES", sysAuthorityService.getGwaesAuthority(inDto));
        }

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwae001(page, inDto);

        return listData;
    }

    /**
     * 归属法人开窗
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_sysorg_biz",description = "归属法人开窗",parameter = "")
    public List<Dto> q_sysorg_biz(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = this.baseMapper.q_sysorg_biz(page, inDto);
        return listData;
    }


    /**
     * 归属法人开窗
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_sysorg_biz_1",description = "归属法人开窗",parameter = "")
    public List<Dto> cq_sysorg_biz_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_sysorg_biz_1(page, inDto);

        if(inDto.getString("ERP").equals("GP")){
            for (int i = 0; i < listData.size(); i++) {
                inDto.put("BIZ_CODE", listData.get(i).getString("BIZ_CODE"));
                Dto resultDto = this.GPMapper.getAzpData(inDto);
                if (resultDto != null) {
                    listData.get(i).put("AZP01", resultDto.getString("AZP01"));
                    listData.get(i).put("AZP02", resultDto.getString("AZP02"));
                } else {
                    listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                    listData.get(i).put("AZP02", "");
                }
            }
        }else if(inDto.getString("ERP").equals("T100")){
            for (int i = 0; i < listData.size(); i++) {
                String querySql=null;
                Dto resultDto = Dtos.newDto();
                inDto.put("BIZ_CODE", listData.get(i).getString("BIZ_CODE"));
                if(!e4jProperties.getDbType().equals("oracle")){
                    querySql="SELECT OOEF001,OOEFL003 FROM OOEF_T A LEFT JOIN OOEFL_T B ON A.OOEFENT=B.OOEFLENT" +
                            " AND A.OOEF001=B.OOEFL001 AND B.OOEFL002=''"+LangUtils.getLang(inDto.getString("LANG"))+"'' " +
                            "WHERE OOEFENT="+inDto.getString("ENT")+" AND OOEF001=''"+
                            inDto.getString("BIZ_CODE")+"'' ";
                    String sqlStr="SELECT * FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+querySql+" ')";
                    inDto.put("sql", sqlStr);
                    resultDto = this.T100Mapper.getOoef(inDto);
                }else {
                    resultDto = this.T100Mapper.getOoefOra(inDto);
                }

                if (resultDto != null) {
                    listData.get(i).put("AZP01", resultDto.getString("OOEF001"));
                    listData.get(i).put("AZP02", resultDto.getString("OOEFL003"));
                } else {
                    listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                    listData.get(i).put("AZP02", "");
                }
            }
        }else if(inDto.getString("ERP").equals("YF")){
            for (int i = 0; i < listData.size(); i++) {
                inDto.put("BIZ_CODE", listData.get(i).getString("BIZ_CODE"));
                Dto resultDto = this.YFMapper.getDSCMB(inDto);
                if (resultDto != null) {
                    listData.get(i).put("AZP01", resultDto.getString("MB001"));
                    listData.get(i).put("AZP02", resultDto.getString("MB002"));
                } else {
                    listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                    listData.get(i).put("AZP02", "");
                }
            }
        }else{
            for (int i = 0; i < listData.size(); i++) {
                listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                listData.get(i).put("AZP02", "");
            }
        }
        return listData;
    }

    /**
     * 产品开窗
     * arg1 ENT
     * arg2 LANG
     *
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwam001_1",description = "产品开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> cq_gwam001_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwam001_1(page, inDto);

        return listData;
    }


    /**
     * 税种开窗
     * arg1 ENT
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwea001",description = "税种开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gwea001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = this.baseMapper.q_gwea001(page, inDto);
        return listData;
    }


    /**
     * 币种开窗
     * arg1 ENT
     * arg2 LANG
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwac001",description = "币种开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwac001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwac001(page, inDto);

        return listData;
    }

    /**
     * 订单号开窗
     * arg1 GWEO002 客户
     * arg2 GWEO006 税种
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwcs_1",description = "订单号开窗",parameter = "{arg1:GWEO002,arg2:GWEO006}")
    public List<Dto> cq_gwcs_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
//        listData = this.baseMapper.cq_gwcs_1(page, inDto);
        listData = InvokeUtil.invokeBeanMethod("queryMapper,cq_gwcs_1",page,inDto);

        return listData;
    }

    /**
     * 回款单号开窗
     * arg1 ENT
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gweo_1",description = "回款单号开窗",parameter = "{arg1:ENT}")
    public List<Dto> cq_gweo_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
//        listData = this.baseMapper.cq_gweo_1(page, inDto);
        listData = InvokeUtil.invokeBeanMethod("queryMapper,cq_gweo_1",page,inDto);

        return listData;
    }

    /**
     * 开票申请单号开窗
     * arg1 ENT
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gweddocno",description = "开票申请单号开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gweddocno(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
//        listData = this.baseMapper.q_gweddocno(page, inDto);
        listData = InvokeUtil.invokeBeanMethod("queryMapper,q_gweddocno",page,inDto);
        return listData;
    }

    /**
     * 发票单号开窗
     * arg1 ENT
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwefdocno",description = "发票单号开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gwefdocno(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
//        listData = this.baseMapper.q_gwefdocno(page, inDto);
        listData = InvokeUtil.invokeBeanMethod("queryMapper,q_gwefdocno",page,inDto);

        return listData;
    }

    /**
     * 产品分类开窗
     * arg1 ENT
     * arg2 LANG
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwah001",description = "产品分类开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwah001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwah001(page, inDto);

        return listData;
    }

    /**
     * 故障开窗
     * arg1 ENT
     * arg2 LANG
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_mmrl001",description = "故障开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_mmrl001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_mmrl001(page, inDto);

        return listData;
    }

    /**
     * 仓库开窗
     * arg1 ENT
     * arg2 LANG
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwas001",description = "仓库开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwas001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwas001(page, inDto);

        return listData;
    }

    /**
     * 产品开窗
     * arg1: keyArrayStr （多选时必传），需要过滤掉的数据的key值
     * arg2: GWAM004 (可选） 产品系列，用来选取某个产品系列下的所有产品
     * arg3:ENT
     * arg4:LANG
     * arg5:GWAM030 大小品号
     *
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwam001",description = "产品开窗",parameter = "{arg1:keyArrayStr,arg2:GWAM004,arg3:ENT,arg4:LANG,arg5:GWAM030}")
    public List<Dto> q_gwam001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //处理多选时过滤记录
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(",");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwam001(page, inDto);

        return listData;
    }

    /**
     * 仓库库位开窗
     * @author mengyb
     * arg1 GWAT001:仓库编号(如果非空则获取该仓库下所属库位)
     * arg2 ENT
     * arg3 LANG
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwat001_1",description = "仓库库位开窗",parameter = "{arg1:GWAT001,arg2:ENT,arg3:LANG}")
    public List<Dto> cq_gwat001_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwat001_1(page, inDto);

        return listData;
    }

    /**
     * 客户开窗(权限+联系人信息)
     * arg1 ENT
     * arg2 LANG
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwak001_4",description = "客户开窗(权限+联系人信息)",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> cq_gwak001_4(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        inDto.put("CUSTOMERS",this.sysAuthorityService.getCustomersAuthority(inDto));

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwak001_4(page, inDto);

        return listData;
    }

    /**
     * 产品开窗(配件)
     * arg1 ENT
     * arg2 LANG
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwam001_2",description = "产品开窗(配件)",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> cq_gwam001_2(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwam001_2(page, inDto);

        return listData;
    }

    /**
     * 客户已购设备开窗
     * arg1 MMRA001:客户编号 前端传入
     * arg2 ENT
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_mmra001_1",description = "客户已购设备开窗",parameter = "{arg1:MMRA001,arg2:ENT}")
    public List<Dto> cq_mmra001_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_mmra001_1(page, inDto);

        return listData;
    }

    /**
     * 商机阶段开窗
     * arg1 ENT
     * arg2 LANG
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwav001",description = "商机阶段开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwav001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = this.baseMapper.q_gwav001(page, inDto);
        return listData;
    }

    /**
     * 商机主题开窗
     * arg1 ENT
     * arg2 LANG
     * arg3 GWBG002:客户编号
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwbg001",description = "商机主题开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWBG002}")
    public List<Dto> q_gwbg001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        //部门权限
        inDto.put("ORGS", sysAuthorityService.getOrgsAuthority(inDto));
        // 业务员权限
        Dto sys004= sysAuthorityService.getSys004(sysAuthorityService.getOrgsAuthority(inDto));
        inDto.put("YWY",sys004.get("ywy"));
        List<Dto> listData = this.baseMapper.q_gwbg001(page, inDto);
        return listData;
    }


    /**
     * 区域开窗
     * arg1 ENG
     * arg2 LANG
     * arg3 GWAD001 区域类型
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwad002",description = "区域开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWAD001}")
    public List<Dto> q_gwad002(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwad002(page, inDto);

        return listData;
    }


    /**
     * 客户等级开窗
     * arg1 ENT
     * arg2 LANG
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwaq001",description = "客户等级开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwaq001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwaq001(page, inDto);

        return listData;
    }

    /**
     * 分类开窗
     * arg1 ENT
     * arg2 GWDE002 分类说明（必传）
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwde003",description = "分类开窗",parameter = "{arg1:ENT,arg2:GWDE002}")
    public List<Dto> q_gwde003(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwde003(page, inDto);

        return listData;
    }

    /**
     * 客户分类开窗
     * arg1 ENT
     * arg2 LANG
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwaf001",description = "客户分类开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwaf001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwaf001(page, inDto);

        return listData;
    }

    /**
     * 行业开窗
     * arg1 ENT
     * arg2 LANG
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwag001",description = "行业开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwag001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwag001(page, inDto);

        return listData;
    }

    /**
     * 产品系列开窗
     * arg1 ENT
     * arg2 LANG
     * arg3 GWAO002 归属产品大类 (可选)
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwao001",description = "产品系列开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWAO002}")
    public List<Dto> q_gwao001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwao001(page, inDto);

        return listData;
    }

    /**
     * 单位开窗
     * arg1 ENT
     * arg2 LANG
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwab001",description = "单位开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwab001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwab001(page, inDto);

        return listData;
    }

    /**
     * 角色开窗
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_sysrole_id",description = "角色开窗",parameter = "")
    public List<Dto> q_sysrole_id(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_sysrole_id(page, inDto);

        return listData;
    }

    /**
     * 交易对象开窗
     * arg1 ENT
     * arg2 LANG
     * arg3 GWAK018:城市
     * arg4 GWAK054:行业
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwak001_5",description = "交易对象开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWAK018,arg4:GWAK054}")
    public List<Dto> cq_gwak001_5(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(";");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }
        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwak001_5(page, inDto);

        return listData;
    }



    /**
     * 属性特征分类开窗
     * arg1: ENT
     * arg2: GWAM005 料号类型 （ 0: 母料号, 1:子料号 ），不传默认按非子料号执行
     * arg3: GWAM006 子料号（类型为 1 时必传）
     *
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwai001",description = "属性特征分类开窗",parameter = "{arg1:ENT,arg2:GWAM005,arg3:GWAM006}")
    public List<Dto> q_gwai001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = new ArrayList<>();

        if (!inDto.getString("GWAM005").equals("1")) { // 非子料号
            listData = this.baseMapper.q_gwai001_0(page, inDto);
        } else { // 子料号
            listData = this.baseMapper.q_gwai001_1(page, inDto);
        }

        return listData;
    }

    /**
     * 经营范围内产品开窗
     * arg1: GWCS010 经销商编号
     * arg2: GWDC001 活动编号
     * arg3: GWCSDOCDATE 单据日期
     *
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwam001_3",description = "经营范围内产品开窗",parameter = "{arg1:GWCS010,arg2:GWDC001,arg3:GWCSDOCDATE}")
    public List<Dto> cq_gwam001_3(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        ShiroUser shiroUser = ShiroKit.getUser();
        inDto.put("TYPE", shiroUser.getTYPE());
        //处理多选时过滤记录
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(",");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }
        List<Dto> listData = this.baseMapper.cq_gwam001_3(page, inDto);
        return listData;
    }


    /**
     * 渠道价格申请单号开窗
     * arg1 ENT
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwdb001",description = "渠道价格申请单号开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gwdb001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwdb001(page, inDto);

        return listData;
    }

    /**
     * 归属法人开窗
     * @author mengyb
     * arg1 ORG_ID 当前用户组织ID
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_sysorg_biz_2",description = "归属法人开窗(权限：根据当前用户组织ID)",parameter = "{arg1:ORG_ID}")
    public List<Dto> cq_sysorg_biz_2(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        ShiroUser shiroUser=ShiroKit.getUser();
        inDto.put("ORG_ID", shiroUser.getORG_ID());

        List<Dto> listData = new ArrayList<>();

//        listData = this.baseMapper.cq_sysorg_biz_2(inDto);
        listData = InvokeUtil.invokeBeanMethod("queryMapper,cq_sysorg_biz_2",inDto);

        if(inDto.getString("ERP").equals("GP")){
            for (int i = 0; i < listData.size(); i++) {
                inDto.put("BIZ_CODE", listData.get(i).getString("BIZ_CODE"));
                Dto resultDto = this.GPMapper.getAzpData(inDto);
                if (resultDto != null) {
                    listData.get(i).put("AZP01", resultDto.getString("AZP01"));
                    listData.get(i).put("AZP02", resultDto.getString("AZP02"));
                } else {
                    listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                    listData.get(i).put("AZP02", "");
                }
            }
        }else if(inDto.getString("ERP").equals("T100")){
            for (int i = 0; i < listData.size(); i++) {
                inDto.put("BIZ_CODE", listData.get(i).getString("BIZ_CODE"));
                String querySql="SELECT OOEF001,OOEFL003 FROM OOEF_T A LEFT JOIN OOEFL_T B ON A.OOEFENT=B.OOEFLENT" +
                        " AND A.OOEF001=B.OOEFL001 AND B.OOEFL002=''"+LangUtils.getLang(inDto.getString("LANG"))+"'' " +
                        "WHERE OOEFENT="+inDto.getString("ENT")+" AND OOEF001=''"+
                        inDto.getString("BIZ_CODE")+"'' ";
                String sqlStr="SELECT * FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+querySql+" ')";
                inDto.put("sql", sqlStr);
                Dto resultDto = this.T100Mapper.getOoef(inDto);
                if (resultDto != null) {
                    listData.get(i).put("AZP01", resultDto.getString("OOEF001"));
                    listData.get(i).put("AZP02", resultDto.getString("OOEFL003"));
                } else {
                    listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                    listData.get(i).put("AZP02", "");
                }
            }
        }else if(inDto.getString("ERP").equals("YF")){
            for (int i = 0; i < listData.size(); i++) {
                inDto.put("BIZ_CODE", listData.get(i).getString("BIZ_CODE"));
                Dto resultDto = this.YFMapper.getDSCMB(inDto);
                if (resultDto != null) {
                    listData.get(i).put("AZP01", resultDto.getString("MB001"));
                    listData.get(i).put("AZP02", resultDto.getString("MB002"));
                } else {
                    listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                    listData.get(i).put("AZP02", "");
                }
            }
        }else{
            for (int i = 0; i < listData.size(); i++) {
                listData.get(i).put("AZP01", listData.get(i).getString("BIZ_CODE"));
                listData.get(i).put("AZP02", "");
            }
        }
        return listData;
    }

    /**
     * 订单单号开窗
     * arg1 ENT
     * arg2 GWCSACTI 订单状态，默认为 'Z' ，已转单
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwcsdocno",description = "订单单号开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gwcsdocno(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        if(inDto.getString("GWCSACTI") == null) {
            inDto.put("GWCSACTI","Z");
        }
//        List<Dto> listData = this.baseMapper.q_gwcsdocno(page, inDto);
        List<Dto> listData = InvokeUtil.invokeBeanMethod("queryMapper,q_gwcsdocno",page,inDto);

        return listData;
    }

    /**
     * ERP订单开窗
     * arg1: TC004 客户编号
     * arg2: mlegal erp营运中心
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_coptc",description = "ERP订单开窗",parameter = "{arg1:TC004,arg2:mlegal}")
    public List<Dto> q_coptc(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                //inDto.put("ERP_Link", "ERP24");
                listData = this.GPMapper.q_coptc(page, inDto);
                break;
            case "T100":
                //inDto.put("ERP_Link", "ERP7");
                String xmdsql = "SELECT DISTINCT XMDADOCNO XMDADOCDT, XMDA004, XMDC055, XMDACNFID, XMDA012, XMDA009 FROM XMDA_T "+
                        "INNER JOIN XMDC_T ON XMDCENT=XMDAENT AND XMDCSITE=XMDASITE AND XMDCDOCNO=XMDADOCNO "+
                        "INNER JOIN (SELECT * FROM XMDD_T WHERE (XMDD005-XMDD014+XMDD015-XMDD016)>0) A ON XMDDSITE=XMDCSITE AND XMDDENT=XMDCENT AND XMDDDOCNO=XMDCDOCNO AND XMDDSEQ=XMDCSEQ "+
                        "WHERE XMDAENT=''"+inDto.getString("ENT")+"'' AND XMDASITE=''"+ inDto.getString("mlegal")+"''";
                String sql = "SELECT B.* FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+ xmdsql+"') B WHERE 1=1";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_coptc(page, inDto);
                break;
            case "YF":
                inDto.put("BIZ_CODE",inDto.getString("mlegal"));
                inDto.put("ERP_DB", AppCxt.getParam("ERP_DB"));
                //inDto.put("ERP_Link", "YF");
                Dto MB003 = this.YFMapper.getDSCMB(inDto);
                inDto.put("MB003", MB003.getString("MB003"));
                listData = this.YFMapper.q_coptc(page, inDto);
                break;
            default:
                break;
        }
        return listData;
    }

    /**
     * ERP订单开窗
     * arg1: TD002 订单单号
     * arg2: mlegal erp营运中心
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_coptd",description = "ERP订单单身开窗",parameter = "{arg1:TD002,arg2:mlegal}")
    public List<Dto> q_coptd(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                //inDto.put("ERP_Link", "ERP24");
                listData = this.GPMapper.q_coptd(page, inDto);
                for (int i = 0; i < listData.size(); i++) {
                    inDto.put("GWAS003", listData.get(i).get("TD007"));
                    Dto gwas003Dto = this.baseMapper.q_gwas003(inDto);
                    if (gwas003Dto != null) {
                        listData.get(i).put("GWCS112", gwas003Dto.getString("GWAS003"));
                        listData.get(i).put("GWCS112_NAME", gwas003Dto.getString("GWAS003_NAME"));
                    } else {
                        listData.get(i).put("GWCS112", null);
                        listData.get(i).put("GWCS112_NAME", null);
                    }
                }
                break;
            case "T100":
                //inDto.put("ERP_Link", "ERP7");
                String xmsql = "SELECT DISTINCT XMDCSEQ AS TD003, XMDC001 AS TD004, XMDC007 AS TD008,XMDC006 AS TD010, XMDC015 AS TD011, XMDC047 AS TD012," +
                        " XMDA015 AS TC008, XMDA016 AS TC009, (XMDD014-XMDD015+XMDD016) AS TH018_SUM, XMDC056 AS TD048, XMDC055 AS TD049, (XMDC047*XMDA016) AS TDI03, "+
                        "XMDA025 FROM XMDC_T INNER JOIN XMDA_T ON XMDCENT=XMDAENT AND XMDCSITE=XMDASITE AND XMDCDOCNO=XMDADOCNO "+
                        "INNER JOIN XMDD_T ON XMDDSITE=XMDCSITE AND XMDDENT=XMDCENT AND XMDDDOCNO=XMDCDOCNO AND XMDDSEQ=XMDCSEQ "+
                        "WHERE XMDCENT=''"+inDto.getString("ENT")+"'' AND XMDCSITE=''"+ inDto.getString("mlegal")+"'' " +
                        "AND (XMDD014-XMDD015+XMDD016) > 0 "+
                        "AND XMDCDOCNO=''"+ inDto.getString("TD002")+"''";
                String openquery = "SELECT A.*, GWAML003 AS TD005, GWAML004 AS TD006, GWCS113 AS TD007 FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+xmsql+"') A ";
                String gwcssql = "LEFT JOIN GWCS_T ON GWCS102=TD003 AND GWCSDOCNO='"+inDto.getString("TD002")+"' AND "+
                        "GWCSENT='"+ inDto.getString("ENT")+"' "+
                        "LEFT JOIN GWAML_T ON GWAML001=TD004 AND GWAMLENT='"+ inDto.getString("ENT")+"' AND GWAML002='"+ inDto.getString("LANG")+"'";
                String sql = "SELECT B.* FROM ("+ openquery + gwcssql+") B WHERE 1=1 ";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_coptd(page, inDto);
                for (int i = 0; i < listData.size(); i++) {
                    inDto.put("GWAS003", listData.get(i).get("TD007"));
                    Dto gwas003Dto = this.baseMapper.q_gwas003(inDto);
                    if (gwas003Dto != null) {
                        listData.get(i).put("GWCS112", gwas003Dto.getString("GWAS003"));
                        listData.get(i).put("GWCS112_NAME", gwas003Dto.getString("GWAS003_NAME"));
                    } else {
                        listData.get(i).put("GWCS112", null);
                        listData.get(i).put("GWCS112_NAME", null);
                    }
                }
                break;
            case "YF":
                inDto.put("BIZ_CODE",inDto.getString("mlegal"));
                inDto.put("ERP_DB", AppCxt.getParam("ERP_DB"));
                //inDto.put("ERP_Link", "YF");
                Dto MB003 = this.YFMapper.getDSCMB(inDto);
                inDto.put("MB003", MB003.getString("MB003"));
                listData = this.YFMapper.q_coptd(page, inDto);
                for (int i = 0; i < listData.size(); i++) {
                    inDto.put("GWAS003", listData.get(i).get("TD007"));
                    Dto gwas003Dto = this.baseMapper.q_gwas003(inDto);
                    if (gwas003Dto != null) {
                        listData.get(i).put("GWCS112", gwas003Dto.getString("GWAS003"));
                        listData.get(i).put("GWCS112_NAME", gwas003Dto.getString("GWAS003_NAME"));
                    } else {
                        listData.get(i).put("GWCS112", null);
                        listData.get(i).put("GWCS112_NAME", null);
                    }
                }
                break;
            default:
                break;
        }
        return listData;
    }

    /**
     * 商机分类开窗
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwau001",description = "商机分类开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwau001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = this.baseMapper.q_gwau001(page, inDto);
        return listData;
    }

    /**
     * 关键评估项开窗
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwbc001",description = "关键评估项开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwbc001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = this.baseMapper.q_gwbc001(page, inDto);
        return listData;
    }

    /**
     * 促销活动开窗
     * arg1 ENT
     * arg2 GWCS010 活动编号
     * arg3 GWCSDOCDATE 单据日期
     * arg4 GWCS117 返利类型
     * @author mengyb
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwdc001",description = "促销活动开窗",parameter = "{arg1:ENT,arg2:GWCS010,arg3:GWCSDOCDATE,arg4:GWDCS117}")
    public List<Dto> q_gwdc001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        Dto gwak = InvokeUtil.invokeBeanMethod("queryMapper,getGwak",inDto);
        if(!(gwak == null)){
            inDto.put("GWAK010", gwak.getString("GWAK010"));
        }
        List<Dto> listData = InvokeUtil.invokeBeanMethod("queryMapper,q_gwdc001",page,inDto);
        return listData;
    }

    /**
     * 费用开窗
     *  arg1 ENT
     *  arg2 LANG
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwfa001",description = "费用编号开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwfa001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = this.baseMapper.q_gwfa001(page, inDto);

        return listData;
    }

    /**
     * 实际费用计算单号开窗
     *  arg1 ENT
     *  arg2 LANG
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwfd001",description = "实际费用计算单号开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwfd001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //处理多选时过滤记录
        if(StringUtils.isNotEmpty(inDto.getString("keyArrayStr"))){
            String keyArrayStr = inDto.getString("keyArrayStr");
            String [] keyArray = keyArrayStr.split(",");
            List<String> keyList=Arrays.asList(keyArray);
            inDto.put("keyList", keyList);
        }

        List<Dto> listData = this.baseMapper.q_gwfd001(page, inDto);

        return listData;
    }

    /**
     * 当前组织及其下级组织开窗
     *  arg ID
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_sys_org",description = "当前组织及其下级组织开窗",parameter = "{arg:ID}")
    public List<Dto> q_sys_org(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        ShiroUser shiroUser = ShiroKit.getUser();
        Dto inDto = dtoWapper.getDto();
        inDto.put("ID",shiroUser.getORG_ID());
        inDto.put("IS_DEL",'0');
        List<Dto> listData = this.baseMapper.q_sys_org(inDto);
        if(listData.size() > 0){
            page.setTotal(Long.valueOf(listData.get(0).get("count").toString()));
        }

        return listData;
    }



    /**
     * 问题提报处理人员开窗
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_esaa010",description = "问题提报处理人员开窗",parameter = "{}")
    public List<Dto> q_esaa010(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_esaa010(page, inDto);

        return listData;
    }

    /**
     * 客户联系人开窗
     *  arg1 ENT
     *  arg2 GWAL001
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwal021",description = "客户联系人开窗",parameter = "{arg1:ENT,arg2:GWAL001}")
    public List<Dto> q_gwal021(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = this.baseMapper.q_gwal021(page, inDto);

        return listData;
    }

    /**
     * 行业一级分类开窗
     *  arg1 ENT
     *  arg2 LANG
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwbw001",description = "行业一级分类开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwbw001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = this.baseMapper.q_gwbw001(page, inDto);

        return listData;
    }

    /**
     * 招标信息开窗
     *  arg1 ENT
     *  arg2 LANG
     *  arg3 GWGAACTI
     *  arg4 GWGC
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwga001",description = "招标信息开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWGAACTI,arg4:GWGC}")
    public List<Dto> q_gwga001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = InvokeUtil.invokeBeanMethod("queryMapper,q_gwga001", page, inDto);

        return listData;
    }

    /**
     * 投标信息开窗
     *  arg1 ENT
     *  arg2 LANG
     *  arg3 GWGG
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwgc001",description = "投标信息开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWGG}")
    public List<Dto> q_gwgc001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        inDto.put("ORGS", sysAuthorityService.getOrgsAuthority(inDto));
        //List<Dto> listData = this.baseMapper.q_gwgc001(page, inDto);
        List<Dto> listData = InvokeUtil.invokeBeanMethod("queryMapper,q_gwgc001", page, inDto);

        return listData;
    }

    /**
     * 投标信息开窗
     *  arg1 ENT
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwgg002",description = "竞争厂商开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gwgg002(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = this.baseMapper.q_gwgg002(page, inDto);

        return listData;
    }

    /**
     * 产品开窗(对品名进行去重)
     * arg1 ENT
     * arg2 LANG
     * @author liuwei
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwaml003",description = "产品开窗",parameter = "{arg1:ENT,arg2:LANG}")
    public List<Dto> q_gwaml003(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwaml003(page, inDto);

        return listData;
    }

    /**
     * 产品开窗(根据品名筛选编号)
     * arg1 ENT
     * arg2 LANG
     * arg3 GWAML003 : 产品说明
     * @author liuwei
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwam001_5",description = "产品开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:产品说明}")
    public List<Dto> cq_gwam001_5(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_gwam001_5(page, inDto);

        return listData;
    }

    /**
     * 销售合同 合同开窗
     *  arg1 ENT
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwca005",description = "合同开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_gwca005(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = this.baseMapper.q_gwca005(page, inDto);

        return listData;
    }

    /**
     * 银行编号开窗
     *  arg1 ENT
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_nmab001",description = "银行编号开窗",parameter = "{arg1:ENT}")
    public List<Dto> q_nmab001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        ShiroUser shiroUser = ShiroKit.getUser();
        Dto inDto = dtoWapper.getDto();
        inDto.put("lang", "zh_CN");

        List<Dto> listData = this.T100Mapper.q_nmab001(page, inDto);

        return listData;
    }

    /**
     * 配置类型
     *  arg1 IMAFUCENT
     *  arg2 IMAFUC001
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_imafuc002",description = "配置类型开窗",parameter = "{arg1:IMAFUCENT,arg2:IMAFUC001}")
    public List<Dto> q_imafuc002(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //List<Dto> listData = this.T100Mapper.q_imafuc002(page, inDto);
        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                break;
            case "T100":
                String xmsql = "SELECT DISTINCT IMAFUC002 FROM IMAFUC_T WHERE IMAFUCENT = " + inDto.getString("ENT")+  " AND IMAFUC001=''"+ inDto.getString("IMAFUC001")+"'' AND IMAFUC002 IS NOT NULL";
                String openquery = "SELECT A.* FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+xmsql+"') A ";
                String sql = "SELECT B.* FROM ("+ openquery + ") B WHERE 1=1 ";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_imafuc002(page, inDto);
                break;
            case "YF":
                break;
            default:
                break;
        }
        return listData;
    }

    /**
     * 动力类型
     *  arg1 IMAFUCENT
     *  arg2 IMAFUC001
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_imafuc003",description = "配置类型开窗",parameter = "{arg1:IMAFUCENT,arg2:IMAFUC001}")
    public List<Dto> q_imafuc003(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //List<Dto> listData = this.T100Mapper.q_imafuc003(page, inDto);
        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                break;
            case "T100":
                String xmsql = "SELECT DISTINCT IMAFUC003 FROM IMAFUC_T WHERE IMAFUCENT = " + inDto.getString("ENT")+  " AND IMAFUC001=''"+ inDto.getString("IMAFUC001")+"'' AND IMAFUC003 IS NOT NULL";
                String openquery = "SELECT A.* FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+xmsql+"') A ";
                String sql = "SELECT B.* FROM ("+ openquery + ") B WHERE 1=1 ";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_imafuc003(page, inDto);
                break;
            case "YF":
                break;
            default:
                break;
        }

        return listData;
    }

    /**
     * 类型
     *  arg1 IMAFUCENT
     *  arg2 IMAFUC001
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_imafuc004",description = "类型开窗",parameter = "{arg1:IMAFUCENT,arg2:IMAFUC001}")
    public List<Dto> q_imafuc004(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //List<Dto> listData = this.T100Mapper.q_imafuc004(page, inDto);
        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                break;
            case "T100":
                String xmsql = "SELECT DISTINCT IMAFUC004 FROM IMAFUC_T WHERE IMAFUCENT = " + inDto.getString("ENT")+  " AND IMAFUC001=''"+ inDto.getString("IMAFUC001")+"'' AND IMAFUC004 IS NOT NULL";
                String openquery = "SELECT A.* FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+xmsql+"') A ";
                String sql = "SELECT B.* FROM ("+ openquery + ") B WHERE 1=1 ";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_imafuc004(page, inDto);
                break;
            case "YF":
                break;
            default:
                break;
        }

        return listData;
    }

    /**
     * 选项说明
     *  arg1 IMAFUCENT
     *  arg2 IMAFUC001
     *  arg3 IMAFUC005
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_imafuc006",description = "选项说明开窗",parameter = "{arg1:IMAFUCENT,arg2:IMAFUC001,arg3:IMAFUC005}")
    public List<Dto> q_imafuc006(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //List<Dto> listData = this.T100Mapper.q_imafuc006(page, inDto);
        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                break;
            case "T100":
                String xmsql = "SELECT DISTINCT IMAFUC006 FROM IMAFUC_T WHERE IMAFUCENT = " + inDto.getString("ENT")+  " AND IMAFUC001=''"+ inDto.getString("IMAFUC001")
                        +  "'' AND IMAFUC004=''"+ inDto.getString("IMAFUC004")
                        +  "'' AND IMAFUC005=''"+ inDto.getString("IMAFUC005")
                        +"'' AND IMAFUC006 IS NOT NULL";
                String openquery = "SELECT A.* FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+xmsql+"') A ";
                String sql = "SELECT B.* FROM ("+ openquery + ") B WHERE 1=1 ";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_imafuc006(page, inDto);
                break;
            case "YF":
                break;
            default:
                break;
        }

        return listData;
    }

    /**
     * 配置说明
     *  arg1 IMAFUCENT
     *  arg2 IMAFUC001
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_imafuc007",description = "配置说明开窗",parameter = "{arg1:IMAFUCENT,arg2:IMAFUC001}")
    public List<Dto> q_imafuc007(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        //List<Dto> listData = this.T100Mapper.q_imafuc007(page, inDto);
        List<Dto> listData = new ArrayList<>();
        switch (inDto.getString("ERP")){
            case "GP":
                break;
            case "T100":
                String xmsql = "SELECT DISTINCT IMAFUC007 FROM IMAFUC_T WHERE IMAFUCENT = " + inDto.getString("ENT")+  " AND IMAFUC001=''"+ inDto.getString("IMAFUC001")
                        +"'' AND IMAFUC007 IS NOT NULL";
                String openquery = "SELECT A.* FROM OPENQUERY("+inDto.getString("ERP_Link")+",'"+xmsql+"') A ";
                String sql = "SELECT B.* FROM ("+ openquery + ") B WHERE 1=1 ";
                inDto.put("sql",sql);
                listData = this.T100Mapper.q_imafuc007(page, inDto);
                break;
            case "YF":
                break;
            default:
                break;
        }
        return listData;
    }

    /**
     * 客户开窗
     *  arg1 ENT
     *  arg2 GWAKACTI
     *  arg3 GWBZ002
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwak001_6",description = "客户资料开窗",parameter = "{arg1:ENT,arg2:GWAKACTI,arg3:GWBZ002}")
    public List<Dto> cq_gwak001_6(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = this.baseMapper.cq_gwak001_6(page, inDto);

        return listData;
    }

    /**
     * 投标信息开窗(无权限)
     *  arg1 ENT
     *  arg2 LANG
     *  arg3 GWGG
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_gwgc001_1",description = "投标信息开窗(无权限)",parameter = "{arg1:ENT,arg2:LANG,arg3:GWGG}")
    public List<Dto> cq_gwgc001_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = InvokeUtil.invokeBeanMethod("queryMapper,cq_gwgc001_1", page, inDto);

        return listData;
    }

    /**
     * 产品资料系列开窗
     *  arg1 ENT
     *  arg2 LANG
     *  arg3 GWAM004
     * @author miaoyl
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwam004",description = "产品资料系列开窗",parameter = "{arg1:ENT,arg2:LANG,arg3:GWAM004}")
    public List<Dto> q_gwam004(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();
        List<Dto> listData = this.baseMapper.q_gwam004(page, inDto);

        return listData;
    }

    /**
     * 客户价值评估单号开窗
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_gwby001",description = "客户价值评估单号开窗",parameter = "{}")
    public List<Dto> q_gwby001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_gwby001(page, inDto);

        return listData;
    }
    /**
     * 问题提报获取客户
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "q_esab001",description = "问题提报获取客户",parameter = "{}")
    public List<Dto> q_esab001(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.q_esab001(page, inDto);

        return listData;
    }

    /**
     * 组织开窗(去除当前组织及其下级组织)
     * arg1 TYPE:组织类型 前端传入
     * arg2 CASCADE_ID:当前组织CASCADE_ID
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_sysorg_id_1",description = "组织开窗",parameter = "{arg1:TYPE}")
    public List<Dto> cq_sysorg_id_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData = new ArrayList<>();
        listData = this.baseMapper.cq_sysorg_id_1(page, inDto);

        return listData;
    }

    /**
     * 模块开窗(去除当前模块及其下级模块)
     * arg1 CASCADE_ID:当前模块CASCADE_ID
     * @author liuw
     * @param dtoWapper
     * @return
     */
    @Transactional(readOnly = true)
    @MethodDescription(method = "cq_sysmodule_id_1",description = "组织开窗",parameter = "{arg1:CASCADE_ID}")
    public List<Dto> cq_sysmodule_id_1(@DtoParam DtoWapper dtoWapper) {
        Page<Object> page = dtoWapper.getPage();
        Dto inDto = dtoWapper.getDto();

        List<Dto> listData;
        listData = this.baseMapper.cq_sysmodule_id_1(page, inDto);

        return listData;
    }
}
